/**********************************************************************\

 Copyright 2012 Diggory Blake

 This file is part of klip-engine

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.

\**********************************************************************/

#include "kanimation.h"
#include "kerror.h"

void kAnimation::createSequence(kSequence* sequence) {
	_sequences.insert(sequence);
}
void kAnimation::deleteSequence(kSequence* sequence) {
	for (auto i = _namedSequences.begin(); i != _namedSequences.end();) {
		auto j = i++;
		if (j->second == sequence)
			_namedSequences.erase(j);
	}

	if (!_sequences.erase(sequence))
		throw kError(_T("Cannot delete sequence!"));
}
kSequence* kAnimation::getSequence(const std::tstring& name) {
	return _namedSequences[name];
}
void kAnimation::registerSequence(const std::tstring& name, kSequence* sequence) {
	if (_sequences.find(sequence) == _sequences.end())
		throw kError(_T("Cannot register sequence!"));
	_namedSequences[name] = sequence;
}
